﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL.Controller;
using EntityObjects;
namespace PresentationLayer.View
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        UpdateStockSupplierControl control = new UpdateStockSupplierControl();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddSupplier.DataSource = control.getSupplier();
                ddSupplier.DataTextField = "SupplierName";
                ddSupplier.DataValueField = "SupplierId";
                ddSupplier.DataBind();
            }
        }

        protected void ddSupplier_SelectedIndexChanged(object sender, EventArgs e)
        {
            string t = ddSupplier.SelectedValue.ToString();
            if (t != "0")
            {
                lblSupplier.Text = ddSupplier.SelectedItem.ToString();
                List<PurchaseOrder> lst = control.getOrder(t);
                if (lst.Count != 0)
                {
                    lblMes.Visible = false;
                    foo.DataSource = lst;

                }
                else
                {
                    lblMes.Visible = true;
                    foo.DataSource = lst;
                }
                foo.DataBind();
            }
        }

        protected void foo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "update")
            {
                string param = e.CommandArgument.ToString();
                Server.Transfer("UpdateStockFromSupplier.aspx?" + param);
            }
        }
    }
}